//
//  TLWalletHeaderView.m
//  WXReader
//
//  Created by huaya on 2025/9/5.
//  Copyright © 2025 Andrew. All rights reserved.
//

#import "TLWalletHeaderView.h"

@interface TLWalletHeaderView ()
@property (weak, nonatomic) IBOutlet UIView *coinView;
@property (weak, nonatomic) IBOutlet UIView *bonusView;
@property (weak, nonatomic) IBOutlet UIButton *getCoinsBtn;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet UILabel *coinLab;
@property (weak, nonatomic) IBOutlet UILabel *bonusLab;

@end

@implementation TLWalletHeaderView

+ (instancetype)createView {
    return [[[NSBundle mainBundle] loadNibNamed:@"TLWalletHeaderView" owner:nil options:nil] lastObject];
}

- (void)awakeFromNib{
    [super awakeFromNib];
    
    
    UITapGestureRecognizer *tapGest = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoBonusListView)];
    
    self.bonusView.userInteractionEnabled = YES;
    
    [self.bonusView addGestureRecognizer:tapGest];
    
    [self loadData];
}
- (void)loadData{
    
    if (TL_UserInfoManager.isLogin) {
        _coinLab.text = [NSString stringWithFormat:@"%@",TL_UserInfoManager.userInfo.coinNum?:@"0"];
        _bonusLab.text = [NSString stringWithFormat:@"%@",TL_UserInfoManager.userInfo.bonusNum?:@"0"];
    }else{
        _coinLab.text = @"0";
        _bonusLab.text = @"0";
    }
}
- (void)gotoBonusListView{
    MK_BLOCK_EXEC(self.gotoBonusListViewBlock);
}
- (IBAction)getCoinsAction:(id)sender {
    
    MK_BLOCK_EXEC(self.gotoRechargeCoinsBlock);
    
}
- (void)drawRect:(CGRect)rect{
    
    self.getCoinsBtn.layer.masksToBounds = YES;
    self.getCoinsBtn.layer.cornerRadius = 20;
    
    [self.bottomView addRoundingCornersWithRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight andCornerRadii:20];
    
}

@end
